{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1a2a0f76",
   "metadata": {},
   "source": [
    "### 上周回顾  \n",
    "* python的基础介绍以及相关软件的了解与安装\n",
    "* 运行 Hello World\n",
    "* 观察标准库 [学习标准库](https://docs.python.org/3/library/index.html) \n",
    "  课本上的观察标准库在P10-11（仅限中文版）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1893abf9",
   "metadata": {},
   "source": [
    "### 本周学习内容  \n",
    "#### 1. 获取[guithub education packages](https://education.github.com/)\n",
    "   * 注意申请学生guithub福利时要使用**学生教育邮箱**\n",
    "  \n",
    "#### 2. pycharm(专业版)的安装和jupyter notebook的安装\n",
    "   * 在[pycharm的官网](https://www.jetbrains.com/pycharm)上下载符合自己电脑系统的**专业版**pycharm\n",
    "   * jupyter notebook的安装（如果已经安装anaconda的配置下可以直接打开从cmd中 就无需安装） \n",
    "   * 安装教程：申请成功后与[Jetbrains](https://www.jetbrains.com/shop/eform/students)关联，将guithub（学生账号）授权给Jetbrains(申请学生福利）；按要求完成后即可获得Jetbrains的许可证（一年），之后再注册该网站的账号；在官网下载好专业版pycharm，登录Jetbrains注册好的账号就可以激活。\n",
    "\n",
    "#### 3.jupyter notebook 的学习使用  \n",
    "* 在jupyter[官网](https://jupyter.org/)上学习相关介绍和基本用法（可以直接在官网上尝试体验）\n",
    "* 用其他浏览器打开jupyter notebook 跳转链接为<http://localhost:8888/> 需要token密码 可以直接在cmd运行中找到即可  \n",
    "* jupyter notebook 可以做代码的系统管理，利用该系统可以做每周的学习笔记（笔记与代码结合多种写法）  \n",
    "  \n",
    "#### 4.快速开始（python）项目一  奇数中选择指定的时间（minute）  \n",
    "* 课本练习——IF语句"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e247a362",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 准备工作（要用到的模块和函数）\n",
    "from datetime import datetime    # 指定某个模块中的某个函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e9c8b614",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "时间是奇数，时间在odds的数据中\n"
     ]
    }
   ],
   "source": [
    "# 课本代码 （项目一：从奇数中选择对应的时间节点）\n",
    "from datetime import datetime\n",
    "\n",
    "odds = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"时间是奇数，时间在odds的数据中\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2d8b3eee",
   "metadata": {},
   "source": [
    "* 关于datetime和time(时间模块) [更多](https://docs.python.org/3/library/datetime.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "86e8b024",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 9, 10, 0, 4, 3, 836537)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3cae1c26",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "950f66d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# time 模块中的sleep函数可以让代码的执行暂停指定的秒数\n",
    "import time\n",
    "time.sleep(5)\n",
    "datetime.today().year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "6521131a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=9, tm_mday=10, tm_hour=23, tm_min=34, tm_sec=30, tm_wday=4, tm_yday=253, tm_isdst=0)"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "b549a3d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1631288288.891804"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time  # 格林威的时间\n",
    "time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ab0ee04",
   "metadata": {},
   "source": [
    "#### 5.变量、数值、数据 \n",
    " \n",
    "1.关于变量的解释<https://www.cnblogs.com/xuzhichao/p/11407192.html>  \n",
    "2.变量定义的规则  \n",
    "  * 变量名只能是 字母、数字或下划线的任意组合\n",
    "  * 变量名的第一个字符不能是数字  \n",
    "  * 以下关键字不能声明为变量名 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "96610237",
   "metadata": {},
   "outputs": [],
   "source": [
    "name=\"cat\"  # name是一个变量名  “=”相当于赋值  cat是一个值（数据）；理解为将右边的值赋给左边的变量（从右往左读）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2558b357",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dog dog\n",
      "cat dog\n"
     ]
    }
   ],
   "source": [
    "# 案例   变量的拓展\n",
    "name1 = \"dog\"\n",
    "name2 = name1\n",
    "print(name1,name2)  # 现在执行一次代码  ## 现在在这个基础上继续给变量赋值看结果\n",
    "\n",
    "name1 = \"cat\"\n",
    "print(name1,name2)  # 同个代码（再赋予新值的情况下）又运行过的不会再运行第二次"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1c709ae",
   "metadata": {},
   "source": [
    "#### 6.数值(int , float) & 字符串(str)\n",
    "  * 更多内容在[学习文档](https://docs.python.org/3/tutorial/introduction.html#using-python-as-a-calculator)\n",
    "  * int:整型或整数，是正或负整数，不带小数点。\n",
    "  * float:浮点型由整数部分与小数部分组成。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "02789092",
   "metadata": {},
   "source": [
    "#### * 数值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5ad74d68",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 数值 利用python可以运算数学公式 运算法则与数学一致\n",
    "# 案例  \n",
    "2+2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a7923847",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "50-4*6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "553e93ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(50-5*6) / 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0ade8bf1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.666666666666667"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一些特殊案例算法  （只针对除法运算  特殊运算符为 //  ，%  ）\n",
    "17/3   # 最后会得出一个值为无限循环小数即为浮点（不是整数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "87ae285d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "17//3  # 在运行除法时 要想获得一个整数则使用 //  最终值会舍去小数部分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "cf213409",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "17%3  # 在除法公式运算中 如果想知道该式子的余数部分则可以使用 %  ，最后就会得出余数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "15816cba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对于幂次方的运算公式 需要用到的运算符号为 **  \n",
    "5**2  #5的2次方"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4223e615",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "740"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# “=”为变量赋值\n",
    "width = 20\n",
    "height = 5 * 9-8\n",
    "width * height"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f02bbe13",
   "metadata": {},
   "source": [
    "#### * 字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "950c1f66",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "单引号表示可以使用\"双引号\"作为字符串的一部分\n",
      "双引号表示可以使用'单引号'作为字符串的一部分\n",
      "三引号中可以使用\"双引号\"\n",
      "'单引号'\n",
      "也可以使用换行\n"
     ]
    }
   ],
   "source": [
    "print('单引号表示可以使用\"双引号\"作为字符串的一部分')\n",
    "print(\"双引号表示可以使用'单引号'作为字符串的一部分\")\n",
    "print('''三引号中可以使用\"双引号\"\n",
    "'单引号'\n",
    "也可以使用换行''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "aa2564b6",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-20-f70cf6904edb>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-20-f70cf6904edb>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    'doesn't'\u001b[0m\n\u001b[1;37m           ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "'doesn't'  # 在引号中还有包含引号时可用\\ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f731002f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'  # 这才是正确的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "a71850be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " \"doesn't\"  # 或者可以使用双引号来保证引号所包含的单引号显示正确"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "b0f8cead",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\"Isn't,\" they said.\n"
     ]
    }
   ],
   "source": [
    "print('\"Isn\\'t,\" they said.')  # 单引号可以把双引号作为字符串的一部分  这时双引号是部分单词的组成部分 所以需要用 \\ 来保证其中的’显示出来"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b7056247",
   "metadata": {},
   "source": [
    "* 转义字符 (\\) 表示该字符与后面相邻的一个字符共同组成了新的含义\n",
    "* \\n 表示换行 \n",
    "* \\\\ 表示反斜杆\n",
    "* \\' 表示单引号\n",
    "* \\'' 表示双引号\n",
    "* \\t 表示水平制表符\n",
    "* \\v 表示垂直制表符\n",
    "\n",
    "**注意在使用这些转义字符时一定要用print()**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "81611fcc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I\n",
      "love\n",
      "Python\t语言\t课程\n"
     ]
    }
   ],
   "source": [
    "print(\"I\\nlove\\nPython\\t语言\\t课程\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "0f5e399f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'First line.\\nSecond line.'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = 'First line.\\nSecond line.'\n",
    "s  # 没有加上 print() 时 \\n 就没有起作用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "10d2c354",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "First line.\n",
      "Second line.\n"
     ]
    }
   ],
   "source": [
    "s = 'First line.\\nSecond line.'\n",
    "print(s)  # 这才是正确"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "65358f84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C:\\some\n",
      "ame\n"
     ]
    }
   ],
   "source": [
    "print('C:\\some\\name')   #这里的\\n是转义符号意味着换行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "15b2f1d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "C:\\some\\name\n"
     ]
    }
   ],
   "source": [
    "print(r'C:\\some\\name')  #如果在引号前面加上  r  则后面的转义就失效"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8106437d",
   "metadata": {},
   "source": [
    "基本字符串操作符  \n",
    "1.x+y  :连接两个字符串和y  \n",
    "2.x * n  或 n * x  :复制n次字符串x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "bfd8f1fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'unununium'"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#案例1\n",
    "3 * 'un' + 'ium'  #表示重复3个un  并与ium合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "09aeeb60",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Python'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#案例2\n",
    "'Py' 'thon'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "b2a706f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'P'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串索引\n",
    "# 在一个字符串（一个英文单词或一句话）从左到右递增 从0开始 \n",
    "word='Python'\n",
    "word[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "b0220645",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'n'"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[-1] # 负数表示从右到左递减（即从右往左数）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "b51eb4d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Py'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# str[N:M] 表示切片，返回索引第N到第M的子串，其中不包含M\n",
    "# 字符串提供区间访问方式，采用[N:M]格式，表示字符串中从N到M（包含N，不包含M）的子字符串，其中M,N为字符串的索引序号。\n",
    "#可以混合使用正向递增序号和反向递减序号。\n",
    "\n",
    "word[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "a1e9b204",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'o'"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[-2:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "d0831162",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Py'"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[:2] #从开始位置到三号索引t即第2个单词(不包含t)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "6bdf4ea2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'on'"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[4:] #从第四个开始到末位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "2e91d79f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'on'"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[4:42] #如果超出字符串的索引范围会自动到字符串的末位\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "5eb1ad36",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[42:] #不在字符串的范围内会无法显示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "5dc14f0c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Python'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[:2] + word[2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "4f7ba044",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Jython'"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'J' + word[1:]  # 这样可以创建一个新的字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "28eccf6d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Pypy'"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word[:2] + 'py'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "390a8af9",
   "metadata": {},
   "source": [
    "#### 7.额外补充关于标准库\n",
    "* 如何快速查看一个标准库模块的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "ea2d462f",
   "metadata": {},
   "outputs": [],
   "source": [
    "? time #在想要了解的模块的前面打上？后运行 就可以了解关于这个模块的所用函数及其用法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "b421a29c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "?? time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccf63997",
   "metadata": {},
   "source": [
    "#### 8.分支语句即 if语句\n",
    "* 根据判断条件选择程序执行路径"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c45d08ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\nif <条件1>:\\n    <语句块1>\\nelif <条件2>:\\n    <语句块2>\\n...\\nelse:\\n    <语句块N>\\n'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 写法：\n",
    "\"\"\"\n",
    "if <条件1>:\n",
    "    <语句块1>\n",
    "elif <条件2>:\n",
    "    <语句块2>\n",
    "...\n",
    "else:\n",
    "    <语句块N>\n",
    "\"\"\"\n",
    "# else后面不添加条件，表示不满足其他if语句的所有其余情况\n",
    "# elif表示为除了if的条件外还有其他多个条件    总结来说 ：if  else只有一个，而elif可以有很多个 "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c03edee0",
   "metadata": {},
   "source": [
    "#### 课本项目和学习记录（第一章）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5d3440f",
   "metadata": {},
   "source": [
    "##### 1.观察标准库  \n",
    "* 学习记录在<https://gitee.com/zhen-liu/python/blob/master/python-work/week_01%E5%AE%9E%E8%B7%B5.ipynb> （内容较多，只有大致清楚主要的7大标准库及其作用，未深入了解各个标准库里的内容。\n",
    "* 以上的标准库学习的基础在于网络上的资源\n",
    "##### 课本标准库学习\n",
    "* “先用import导入模块\n",
    "* 所调用的模块.该模块下的函数（属性）”      \n",
    "* 注意这里的“ . 表示调用并且后面跟着的属性只在该模块下的函数\n",
    "* 所以说标准库是由模块和函数组成的即：**函数+模块=标准库**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c40a7b6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'win32'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sys      # sys模块用于你所在运行解释器的系统 \n",
    "sys.platform    # platform 预置属性可以确定当下你所使用的底层操作系统     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3a4eff30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\LZ\\\\Python课程\\\\笔记'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os     # os 模块主要用于提供功能\n",
    "os.getcwd()    # getcwd 函数用于得出代码所在文件夹的名字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3dbdc9c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "environ{'ALLUSERSPROFILE': 'C:\\\\ProgramData',\n",
       "        'APPDATA': 'C:\\\\Users\\\\LZ\\\\AppData\\\\Roaming',\n",
       "        'COMMONPROGRAMFILES': 'C:\\\\Program Files\\\\Common Files',\n",
       "        'COMMONPROGRAMFILES(X86)': 'C:\\\\Program Files (x86)\\\\Common Files',\n",
       "        'COMMONPROGRAMW6432': 'C:\\\\Program Files\\\\Common Files',\n",
       "        'COMPUTERNAME': 'DESKTOP-D7APHE7',\n",
       "        'COMSPEC': 'C:\\\\Windows\\\\system32\\\\cmd.exe',\n",
       "        'DRIVERDATA': 'C:\\\\Windows\\\\System32\\\\Drivers\\\\DriverData',\n",
       "        'HOMEDRIVE': 'C:',\n",
       "        'HOMEPATH': '\\\\Users\\\\LZ',\n",
       "        'INTEL_DEV_REDIST': 'C:\\\\Program Files (x86)\\\\Common Files\\\\Intel\\\\Shared Libraries\\\\',\n",
       "        'LOCALAPPDATA': 'C:\\\\Users\\\\LZ\\\\AppData\\\\Local',\n",
       "        'LOGONSERVER': '\\\\\\\\DESKTOP-D7APHE7',\n",
       "        'MIC_LD_LIBRARY_PATH': 'C:\\\\Program Files (x86)\\\\Common Files\\\\Intel\\\\Shared Libraries\\\\compiler\\\\lib\\\\mic',\n",
       "        'NUMBER_OF_PROCESSORS': '8',\n",
       "        'ONEDRIVE': 'C:\\\\Users\\\\LZ\\\\OneDrive',\n",
       "        'ONEDRIVECONSUMER': 'C:\\\\Users\\\\LZ\\\\OneDrive',\n",
       "        'OS': 'Windows_NT',\n",
       "        'PATH': 'C:\\\\ProgramData\\\\Anaconda3;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\mingw-w64\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\usr\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Scripts;C:\\\\Program Files (x86)\\\\Common Files\\\\Intel\\\\Shared Libraries\\\\redist\\\\intel64\\\\compiler;C:\\\\Windows\\\\system32;C:\\\\Windows;C:\\\\Windows\\\\System32\\\\Wbem;C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\;C:\\\\Windows\\\\System32\\\\OpenSSH\\\\;C:\\\\Program Files (x86)\\\\NVIDIA Corporation\\\\PhysX\\\\Common;C:\\\\Program Files\\\\NVIDIA Corporation\\\\NVIDIA NvDLISR;C:\\\\Users\\\\LZ\\\\AppData\\\\Local\\\\Microsoft\\\\WindowsApps;C:\\\\Users\\\\LZ\\\\AppData\\\\Local\\\\GitHubDesktop\\\\bin;C:\\\\Program Files\\\\JetBrains\\\\PyCharm 2021.2.1\\\\bin;',\n",
       "        'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',\n",
       "        'PROCESSOR_ARCHITECTURE': 'AMD64',\n",
       "        'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 142 Stepping 12, GenuineIntel',\n",
       "        'PROCESSOR_LEVEL': '6',\n",
       "        'PROCESSOR_REVISION': '8e0c',\n",
       "        'PROGRAMDATA': 'C:\\\\ProgramData',\n",
       "        'PROGRAMFILES': 'C:\\\\Program Files',\n",
       "        'PROGRAMFILES(X86)': 'C:\\\\Program Files (x86)',\n",
       "        'PROGRAMW6432': 'C:\\\\Program Files',\n",
       "        'PROMPT': '$P$G',\n",
       "        'PSMODULEPATH': 'C:\\\\Program Files\\\\WindowsPowerShell\\\\Modules;C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\Modules',\n",
       "        'PUBLIC': 'C:\\\\Users\\\\Public',\n",
       "        'PYCHARM': 'C:\\\\Program Files\\\\JetBrains\\\\PyCharm 2021.2.1\\\\bin;',\n",
       "        'SESSIONNAME': 'Console',\n",
       "        'SYSTEMDRIVE': 'C:',\n",
       "        'SYSTEMROOT': 'C:\\\\Windows',\n",
       "        'TEMP': 'C:\\\\Users\\\\LZ\\\\AppData\\\\Local\\\\Temp',\n",
       "        'TMP': 'C:\\\\Users\\\\LZ\\\\AppData\\\\Local\\\\Temp',\n",
       "        'USERDOMAIN': 'DESKTOP-D7APHE7',\n",
       "        'USERDOMAIN_ROAMINGPROFILE': 'DESKTOP-D7APHE7',\n",
       "        'USERNAME': 'LZ',\n",
       "        'USERPROFILE': 'C:\\\\Users\\\\LZ',\n",
       "        'WINDIR': 'C:\\\\Windows',\n",
       "        'JPY_INTERRUPT_EVENT': '2568',\n",
       "        'IPY_INTERRUPT_EVENT': '2568',\n",
       "        'JPY_PARENT_PID': '2576',\n",
       "        'TERM': 'xterm-color',\n",
       "        'CLICOLOR': '1',\n",
       "        'PAGER': 'cat',\n",
       "        'GIT_PAGER': 'cat',\n",
       "        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.environ  # 该函数用于访问系统的全部环境变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "eb2ace48",
   "metadata": {},
   "outputs": [],
   "source": [
    "os.getenv('C')    # getenv 函数用于从environ中即上列运行代码结果中访问指定的属性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "28d58307",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 10, 9)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime   #  datetime 模块是用于处理日期\n",
    "datetime.date.today()  # 今天的日期"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "52d3380c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().year      # 在today()后面调用特定属性会更加具体"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "fb4cabcd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-10-09'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.isoformat(datetime.date.today())  # isoformat函数是格式化时间 将时间转化为字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "268a6b22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'16:54'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time        # time 模块用于处理时间\n",
    "time.strftime(\"%H:%M\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ae4ff142",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Saturday:PM'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.strftime(\"%A:%p\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "1042e336",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in module time:\n",
      "\n",
      "NAME\n",
      "    time - This module provides various functions to manipulate time values.\n",
      "\n",
      "DESCRIPTION\n",
      "    There are two standard representations of time.  One is the number\n",
      "    of seconds since the Epoch, in UTC (a.k.a. GMT).  It may be an integer\n",
      "    or a floating point number (to represent fractions of seconds).\n",
      "    The Epoch is system-defined; on Unix, it is generally January 1st, 1970.\n",
      "    The actual value can be retrieved by calling gmtime(0).\n",
      "    \n",
      "    The other representation is a tuple of 9 integers giving local time.\n",
      "    The tuple items are:\n",
      "      year (including century, e.g. 1998)\n",
      "      month (1-12)\n",
      "      day (1-31)\n",
      "      hours (0-23)\n",
      "      minutes (0-59)\n",
      "      seconds (0-59)\n",
      "      weekday (0-6, Monday is 0)\n",
      "      Julian day (day in the year, 1-366)\n",
      "      DST (Daylight Savings Time) flag (-1, 0 or 1)\n",
      "    If the DST flag is 0, the time is given in the regular time zone;\n",
      "    if it is 1, the time is given in the DST time zone;\n",
      "    if it is -1, mktime() should guess based on the date and time.\n",
      "\n",
      "CLASSES\n",
      "    builtins.tuple(builtins.object)\n",
      "        struct_time\n",
      "    \n",
      "    class struct_time(builtins.tuple)\n",
      "     |  struct_time(iterable=(), /)\n",
      "     |  \n",
      "     |  The time value as returned by gmtime(), localtime(), and strptime(), and\n",
      "     |  accepted by asctime(), mktime() and strftime().  May be considered as a\n",
      "     |  sequence of 9 integers.\n",
      "     |  \n",
      "     |  Note that several fields' values are not the same as those defined by\n",
      "     |  the C language standard for struct tm.  For example, the value of the\n",
      "     |  field tm_year is the actual year, not year - 1900.  See individual\n",
      "     |  fields' descriptions for details.\n",
      "     |  \n",
      "     |  Method resolution order:\n",
      "     |      struct_time\n",
      "     |      builtins.tuple\n",
      "     |      builtins.object\n",
      "     |  \n",
      "     |  Methods defined here:\n",
      "     |  \n",
      "     |  __reduce__(...)\n",
      "     |      Helper for pickle.\n",
      "     |  \n",
      "     |  __repr__(self, /)\n",
      "     |      Return repr(self).\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Static methods defined here:\n",
      "     |  \n",
      "     |  __new__(*args, **kwargs) from builtins.type\n",
      "     |      Create and return a new object.  See help(type) for accurate signature.\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data descriptors defined here:\n",
      "     |  \n",
      "     |  tm_gmtoff\n",
      "     |      offset from UTC in seconds\n",
      "     |  \n",
      "     |  tm_hour\n",
      "     |      hours, range [0, 23]\n",
      "     |  \n",
      "     |  tm_isdst\n",
      "     |      1 if summer time is in effect, 0 if not, and -1 if unknown\n",
      "     |  \n",
      "     |  tm_mday\n",
      "     |      day of month, range [1, 31]\n",
      "     |  \n",
      "     |  tm_min\n",
      "     |      minutes, range [0, 59]\n",
      "     |  \n",
      "     |  tm_mon\n",
      "     |      month of year, range [1, 12]\n",
      "     |  \n",
      "     |  tm_sec\n",
      "     |      seconds, range [0, 61])\n",
      "     |  \n",
      "     |  tm_wday\n",
      "     |      day of week, range [0, 6], Monday is 0\n",
      "     |  \n",
      "     |  tm_yday\n",
      "     |      day of year, range [1, 366]\n",
      "     |  \n",
      "     |  tm_year\n",
      "     |      year, for example, 1993\n",
      "     |  \n",
      "     |  tm_zone\n",
      "     |      abbreviation of timezone name\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Data and other attributes defined here:\n",
      "     |  \n",
      "     |  n_fields = 11\n",
      "     |  \n",
      "     |  n_sequence_fields = 9\n",
      "     |  \n",
      "     |  n_unnamed_fields = 0\n",
      "     |  \n",
      "     |  ----------------------------------------------------------------------\n",
      "     |  Methods inherited from builtins.tuple:\n",
      "     |  \n",
      "     |  __add__(self, value, /)\n",
      "     |      Return self+value.\n",
      "     |  \n",
      "     |  __contains__(self, key, /)\n",
      "     |      Return key in self.\n",
      "     |  \n",
      "     |  __eq__(self, value, /)\n",
      "     |      Return self==value.\n",
      "     |  \n",
      "     |  __ge__(self, value, /)\n",
      "     |      Return self>=value.\n",
      "     |  \n",
      "     |  __getattribute__(self, name, /)\n",
      "     |      Return getattr(self, name).\n",
      "     |  \n",
      "     |  __getitem__(self, key, /)\n",
      "     |      Return self[key].\n",
      "     |  \n",
      "     |  __getnewargs__(self, /)\n",
      "     |  \n",
      "     |  __gt__(self, value, /)\n",
      "     |      Return self>value.\n",
      "     |  \n",
      "     |  __hash__(self, /)\n",
      "     |      Return hash(self).\n",
      "     |  \n",
      "     |  __iter__(self, /)\n",
      "     |      Implement iter(self).\n",
      "     |  \n",
      "     |  __le__(self, value, /)\n",
      "     |      Return self<=value.\n",
      "     |  \n",
      "     |  __len__(self, /)\n",
      "     |      Return len(self).\n",
      "     |  \n",
      "     |  __lt__(self, value, /)\n",
      "     |      Return self<value.\n",
      "     |  \n",
      "     |  __mul__(self, value, /)\n",
      "     |      Return self*value.\n",
      "     |  \n",
      "     |  __ne__(self, value, /)\n",
      "     |      Return self!=value.\n",
      "     |  \n",
      "     |  __rmul__(self, value, /)\n",
      "     |      Return value*self.\n",
      "     |  \n",
      "     |  count(self, value, /)\n",
      "     |      Return number of occurrences of value.\n",
      "     |  \n",
      "     |  index(self, value, start=0, stop=9223372036854775807, /)\n",
      "     |      Return first index of value.\n",
      "     |      \n",
      "     |      Raises ValueError if the value is not present.\n",
      "\n",
      "FUNCTIONS\n",
      "    asctime(...)\n",
      "        asctime([tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n",
      "        When the time tuple is not present, current time as returned by localtime()\n",
      "        is used.\n",
      "    \n",
      "    ctime(...)\n",
      "        ctime(seconds) -> string\n",
      "        \n",
      "        Convert a time in seconds since the Epoch to a string in local time.\n",
      "        This is equivalent to asctime(localtime(seconds)). When the time tuple is\n",
      "        not present, current time as returned by localtime() is used.\n",
      "    \n",
      "    get_clock_info(...)\n",
      "        get_clock_info(name: str) -> dict\n",
      "        \n",
      "        Get information of the specified clock.\n",
      "    \n",
      "    gmtime(...)\n",
      "        gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n",
      "                               tm_sec, tm_wday, tm_yday, tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n",
      "        GMT).  When 'seconds' is not passed in, convert the current time instead.\n",
      "        \n",
      "        If the platform supports the tm_gmtoff and tm_zone, they are available as\n",
      "        attributes only.\n",
      "    \n",
      "    localtime(...)\n",
      "        localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n",
      "                                  tm_sec,tm_wday,tm_yday,tm_isdst)\n",
      "        \n",
      "        Convert seconds since the Epoch to a time tuple expressing local time.\n",
      "        When 'seconds' is not passed in, convert the current time instead.\n",
      "    \n",
      "    mktime(...)\n",
      "        mktime(tuple) -> floating point number\n",
      "        \n",
      "        Convert a time tuple in local time to seconds since the Epoch.\n",
      "        Note that mktime(gmtime(0)) will not generally return zero for most\n",
      "        time zones; instead the returned value will either be equal to that\n",
      "        of the timezone or altzone attributes on the time module.\n",
      "    \n",
      "    monotonic(...)\n",
      "        monotonic() -> float\n",
      "        \n",
      "        Monotonic clock, cannot go backward.\n",
      "    \n",
      "    monotonic_ns(...)\n",
      "        monotonic_ns() -> int\n",
      "        \n",
      "        Monotonic clock, cannot go backward, as nanoseconds.\n",
      "    \n",
      "    perf_counter(...)\n",
      "        perf_counter() -> float\n",
      "        \n",
      "        Performance counter for benchmarking.\n",
      "    \n",
      "    perf_counter_ns(...)\n",
      "        perf_counter_ns() -> int\n",
      "        \n",
      "        Performance counter for benchmarking as nanoseconds.\n",
      "    \n",
      "    process_time(...)\n",
      "        process_time() -> float\n",
      "        \n",
      "        Process time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    process_time_ns(...)\n",
      "        process_time() -> int\n",
      "        \n",
      "        Process time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    sleep(...)\n",
      "        sleep(seconds)\n",
      "        \n",
      "        Delay execution for a given number of seconds.  The argument may be\n",
      "        a floating point number for subsecond precision.\n",
      "    \n",
      "    strftime(...)\n",
      "        strftime(format[, tuple]) -> string\n",
      "        \n",
      "        Convert a time tuple to a string according to a format specification.\n",
      "        See the library reference manual for formatting codes. When the time tuple\n",
      "        is not present, current time as returned by localtime() is used.\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    strptime(...)\n",
      "        strptime(string, format) -> struct_time\n",
      "        \n",
      "        Parse a string to a time tuple according to a format specification.\n",
      "        See the library reference manual for formatting codes (same as\n",
      "        strftime()).\n",
      "        \n",
      "        Commonly used format codes:\n",
      "        \n",
      "        %Y  Year with century as a decimal number.\n",
      "        %m  Month as a decimal number [01,12].\n",
      "        %d  Day of the month as a decimal number [01,31].\n",
      "        %H  Hour (24-hour clock) as a decimal number [00,23].\n",
      "        %M  Minute as a decimal number [00,59].\n",
      "        %S  Second as a decimal number [00,61].\n",
      "        %z  Time zone offset from UTC.\n",
      "        %a  Locale's abbreviated weekday name.\n",
      "        %A  Locale's full weekday name.\n",
      "        %b  Locale's abbreviated month name.\n",
      "        %B  Locale's full month name.\n",
      "        %c  Locale's appropriate date and time representation.\n",
      "        %I  Hour (12-hour clock) as a decimal number [01,12].\n",
      "        %p  Locale's equivalent of either AM or PM.\n",
      "        \n",
      "        Other codes may be available on your platform.  See documentation for\n",
      "        the C library strftime function.\n",
      "    \n",
      "    thread_time(...)\n",
      "        thread_time() -> float\n",
      "        \n",
      "        Thread time for profiling: sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    thread_time_ns(...)\n",
      "        thread_time() -> int\n",
      "        \n",
      "        Thread time for profiling as nanoseconds:\n",
      "        sum of the kernel and user-space CPU time.\n",
      "    \n",
      "    time(...)\n",
      "        time() -> floating point number\n",
      "        \n",
      "        Return the current time in seconds since the Epoch.\n",
      "        Fractions of a second may be present if the system clock provides them.\n",
      "    \n",
      "    time_ns(...)\n",
      "        time_ns() -> int\n",
      "        \n",
      "        Return the current time in nanoseconds since the Epoch.\n",
      "\n",
      "DATA\n",
      "    altzone = -32400\n",
      "    daylight = 0\n",
      "    timezone = -28800\n",
      "    tzname = ('中国标准时间', '中国夏令时')\n",
      "\n",
      "FILE\n",
      "    (built-in)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "ac24fa92",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "escape() missing 1 required positional argument: 's'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-20-b0bd0d189a7d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mhtml\u001b[0m   \u001b[1;31m# escape函数可以对HTML进行转换为编码 再存储\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mhtml\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mescape\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: escape() missing 1 required positional argument: 's'"
     ]
    }
   ],
   "source": [
    "import html  \n",
    "html.escape()   # escape函数可以对HTML进行转换为编码——存储\n",
    "html.unescape()  # unescape函数是对已经编码的HTML进行转换为HTML ——提取  # 这两个函数实现了对HTML的来回转换"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccc24318",
   "metadata": {},
   "source": [
    "#### 2.python 的变量、赋值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8acedb9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = {1,3,5,7,9}\n",
    "# odds 是变量， {1，3，5，7，9}是一个值 只不过这里的值为一个列表  中间的“=”表示赋值  所以相当于右边的值赋值给左边的变量（记住在python中的“等式”其实是赋值的一个过程）\n",
    "# 对于变量的命名也是有规定的 以及变量的拓展 具体向上看第 5.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f8e2f912",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 调用内置函数模块\n",
    "from datetime import datetime  # 导入模块\n",
    "time_now = datetime.today()     # 理解 变量time_now 被赋上今天的日期（detetime中调用的是today属性），接着调用刚刚那个time_now的minute属性(.minute)赋值给一个新的变量right_this_minute\n",
    "right_this_minute = time_now.minute"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b81c026",
   "metadata": {},
   "source": [
    "#### 3. python 中的缩进 （！！！ 如果运行代码时显示错误 代码无误的情况下很有可能是缩进问题所致）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ab129d4",
   "metadata": {},
   "source": [
    "1. python使用缩进来表示代码块\n",
    "2. 冒号(:) 引入一个缩进的代码组  简单来说当看见冒号时就要换行并且向右缩进\n",
    "3. 代码组可以嵌套多个代码组 \n",
    "4. 缩进层次：也就是说缩进其实可以表示层级，不同的缩进表示不同级别，所以在运用缩进时要考虑代码块是否为同一级\n",
    "* 注意Dell窗口 会帮你自动缩进，但一定要考虑到是否符合自己想要的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "855ad82d",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'today' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-15-f902ccc1dda6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mdatetime\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mtoday\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'Saturday'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'Part!'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mtoday\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'Sunday'\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'today' is not defined"
     ]
    }
   ],
   "source": [
    "# 缩进的案例\n",
    "import datetime     # 有相同缩进的代码块为同一组 在多个条件语句中经常用到缩进层次\n",
    "\n",
    "if today == 'Saturday':\n",
    "    print('Part!')\n",
    "elif today == 'Sunday':\n",
    "    if condition == 'Headache':\n",
    "        print('Recover,then rest.')\n",
    "    else:\n",
    "        print('Rest.')\n",
    "else:\n",
    "    print('Work,work,work.')      "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6ff9bfdb",
   "metadata": {},
   "source": [
    "#### 课本项目练习一： 时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5b317cf8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "odds = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Now an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec60b2bc",
   "metadata": {},
   "source": [
    "#### 3.for 循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f9241642",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# for循环一个列表\n",
    "for i in [1,2,3]:   #这里的i是一个循环变量\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bf03e755",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "for ch in \"Hi!\":   # 同样for也可以循环字符串\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "37e45038",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A\n",
      "A\n",
      "A\n",
      "A\n",
      "A\n"
     ]
    }
   ],
   "source": [
    "for num in range(5):      # 循环指定的次数用 range函数\n",
    "    print(\"A\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66c0ceb6",
   "metadata": {},
   "source": [
    "#### 课本项目二练习：for循环"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "fe9127aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n",
      "Not an odd minute.\n",
      "This minute seems a little odd.\n",
      "This minute seems a little odd.\n",
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "import random\n",
    "import time\n",
    "\n",
    "odds = {1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59}\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_minute = datetime.today().minute\n",
    "    if right_this_minute in odds:\n",
    "        print(\"This minute seems a little odd.\")\n",
    "    else:\n",
    "        print(\"Not an odd minute.\")\n",
    "    wait_time = random.randint(1,60)\n",
    "    time.sleep(wait_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "72d50e6e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello word\n"
     ]
    }
   ],
   "source": [
    "# 程序执行的暂停时间用sleep  time.sleep(暂停的秒数)\n",
    "import time\n",
    "print(\"hello word\")\n",
    "time.sleep(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "abeeeb8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['BPF',\n",
       " 'LOG4',\n",
       " 'NV_MAGICCONST',\n",
       " 'RECIP_BPF',\n",
       " 'Random',\n",
       " 'SG_MAGICCONST',\n",
       " 'SystemRandom',\n",
       " 'TWOPI',\n",
       " '_Sequence',\n",
       " '_Set',\n",
       " '__all__',\n",
       " '__builtins__',\n",
       " '__cached__',\n",
       " '__doc__',\n",
       " '__file__',\n",
       " '__loader__',\n",
       " '__name__',\n",
       " '__package__',\n",
       " '__spec__',\n",
       " '_accumulate',\n",
       " '_acos',\n",
       " '_bisect',\n",
       " '_ceil',\n",
       " '_cos',\n",
       " '_e',\n",
       " '_exp',\n",
       " '_inst',\n",
       " '_log',\n",
       " '_os',\n",
       " '_pi',\n",
       " '_random',\n",
       " '_repeat',\n",
       " '_sha512',\n",
       " '_sin',\n",
       " '_sqrt',\n",
       " '_test',\n",
       " '_test_generator',\n",
       " '_urandom',\n",
       " '_warn',\n",
       " 'betavariate',\n",
       " 'choice',\n",
       " 'choices',\n",
       " 'expovariate',\n",
       " 'gammavariate',\n",
       " 'gauss',\n",
       " 'getrandbits',\n",
       " 'getstate',\n",
       " 'lognormvariate',\n",
       " 'normalvariate',\n",
       " 'paretovariate',\n",
       " 'randint',\n",
       " 'random',\n",
       " 'randrange',\n",
       " 'sample',\n",
       " 'seed',\n",
       " 'setstate',\n",
       " 'shuffle',\n",
       " 'triangular',\n",
       " 'uniform',\n",
       " 'vonmisesvariate',\n",
       " 'weibullvariate']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 在给定范围中生成随机数\n",
    "# 补充：用dir 可以查询一个对象的所有属性(该模块下的所有函数)\n",
    "\n",
    "import random\n",
    "dir(random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "08919fdb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method randint in module random:\n",
      "\n",
      "randint(a, b) method of random.Random instance\n",
      "    Return random integer in range [a, b], including both end points.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 查询某个函数的使用方法是help\n",
    "help(random.randint)   # 这样就可以快速查询到randint的使用方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "eae13cae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# randint 就是一个随机函数 给个范围就会在当中随机取值\n",
    "random.randint(1,60)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53421d5f",
   "metadata": {},
   "source": [
    "#### 课本项目三练习 ：range函数  \n",
    "* 更多笔记在第三章笔记"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "73502e08",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles of beer on the wall.\n",
      "99 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "98 bottles of beer on the wall.\n",
      "\n",
      "98 bottles of beer on the wall.\n",
      "98 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "97 bottles of beer on the wall.\n",
      "\n",
      "97 bottles of beer on the wall.\n",
      "97 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "96 bottles of beer on the wall.\n",
      "\n",
      "96 bottles of beer on the wall.\n",
      "96 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "95 bottles of beer on the wall.\n",
      "\n",
      "95 bottles of beer on the wall.\n",
      "95 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "94 bottles of beer on the wall.\n",
      "\n",
      "94 bottles of beer on the wall.\n",
      "94 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "93 bottles of beer on the wall.\n",
      "\n",
      "93 bottles of beer on the wall.\n",
      "93 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "92 bottles of beer on the wall.\n",
      "\n",
      "92 bottles of beer on the wall.\n",
      "92 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "91 bottles of beer on the wall.\n",
      "\n",
      "91 bottles of beer on the wall.\n",
      "91 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "90 bottles of beer on the wall.\n",
      "\n",
      "90 bottles of beer on the wall.\n",
      "90 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "89 bottles of beer on the wall.\n",
      "\n",
      "89 bottles of beer on the wall.\n",
      "89 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "88 bottles of beer on the wall.\n",
      "\n",
      "88 bottles of beer on the wall.\n",
      "88 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "87 bottles of beer on the wall.\n",
      "\n",
      "87 bottles of beer on the wall.\n",
      "87 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "86 bottles of beer on the wall.\n",
      "\n",
      "86 bottles of beer on the wall.\n",
      "86 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "85 bottles of beer on the wall.\n",
      "\n",
      "85 bottles of beer on the wall.\n",
      "85 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "84 bottles of beer on the wall.\n",
      "\n",
      "84 bottles of beer on the wall.\n",
      "84 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "83 bottles of beer on the wall.\n",
      "\n",
      "83 bottles of beer on the wall.\n",
      "83 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "82 bottles of beer on the wall.\n",
      "\n",
      "82 bottles of beer on the wall.\n",
      "82 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "81 bottles of beer on the wall.\n",
      "\n",
      "81 bottles of beer on the wall.\n",
      "81 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "80 bottles of beer on the wall.\n",
      "\n",
      "80 bottles of beer on the wall.\n",
      "80 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "79 bottles of beer on the wall.\n",
      "\n",
      "79 bottles of beer on the wall.\n",
      "79 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "78 bottles of beer on the wall.\n",
      "\n",
      "78 bottles of beer on the wall.\n",
      "78 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "77 bottles of beer on the wall.\n",
      "\n",
      "77 bottles of beer on the wall.\n",
      "77 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "76 bottles of beer on the wall.\n",
      "\n",
      "76 bottles of beer on the wall.\n",
      "76 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "75 bottles of beer on the wall.\n",
      "\n",
      "75 bottles of beer on the wall.\n",
      "75 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "74 bottles of beer on the wall.\n",
      "\n",
      "74 bottles of beer on the wall.\n",
      "74 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "73 bottles of beer on the wall.\n",
      "\n",
      "73 bottles of beer on the wall.\n",
      "73 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "72 bottles of beer on the wall.\n",
      "\n",
      "72 bottles of beer on the wall.\n",
      "72 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "71 bottles of beer on the wall.\n",
      "\n",
      "71 bottles of beer on the wall.\n",
      "71 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "70 bottles of beer on the wall.\n",
      "\n",
      "70 bottles of beer on the wall.\n",
      "70 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "69 bottles of beer on the wall.\n",
      "\n",
      "69 bottles of beer on the wall.\n",
      "69 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "68 bottles of beer on the wall.\n",
      "\n",
      "68 bottles of beer on the wall.\n",
      "68 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "67 bottles of beer on the wall.\n",
      "\n",
      "67 bottles of beer on the wall.\n",
      "67 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "66 bottles of beer on the wall.\n",
      "\n",
      "66 bottles of beer on the wall.\n",
      "66 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "65 bottles of beer on the wall.\n",
      "\n",
      "65 bottles of beer on the wall.\n",
      "65 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "64 bottles of beer on the wall.\n",
      "\n",
      "64 bottles of beer on the wall.\n",
      "64 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "63 bottles of beer on the wall.\n",
      "\n",
      "63 bottles of beer on the wall.\n",
      "63 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "62 bottles of beer on the wall.\n",
      "\n",
      "62 bottles of beer on the wall.\n",
      "62 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "61 bottles of beer on the wall.\n",
      "\n",
      "61 bottles of beer on the wall.\n",
      "61 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "60 bottles of beer on the wall.\n",
      "\n",
      "60 bottles of beer on the wall.\n",
      "60 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "59 bottles of beer on the wall.\n",
      "\n",
      "59 bottles of beer on the wall.\n",
      "59 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "58 bottles of beer on the wall.\n",
      "\n",
      "58 bottles of beer on the wall.\n",
      "58 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "57 bottles of beer on the wall.\n",
      "\n",
      "57 bottles of beer on the wall.\n",
      "57 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "56 bottles of beer on the wall.\n",
      "\n",
      "56 bottles of beer on the wall.\n",
      "56 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "55 bottles of beer on the wall.\n",
      "\n",
      "55 bottles of beer on the wall.\n",
      "55 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "54 bottles of beer on the wall.\n",
      "\n",
      "54 bottles of beer on the wall.\n",
      "54 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "53 bottles of beer on the wall.\n",
      "\n",
      "53 bottles of beer on the wall.\n",
      "53 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "52 bottles of beer on the wall.\n",
      "\n",
      "52 bottles of beer on the wall.\n",
      "52 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "51 bottles of beer on the wall.\n",
      "\n",
      "51 bottles of beer on the wall.\n",
      "51 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "50 bottles of beer on the wall.\n",
      "\n",
      "50 bottles of beer on the wall.\n",
      "50 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "49 bottles of beer on the wall.\n",
      "\n",
      "49 bottles of beer on the wall.\n",
      "49 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "48 bottles of beer on the wall.\n",
      "\n",
      "48 bottles of beer on the wall.\n",
      "48 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "47 bottles of beer on the wall.\n",
      "\n",
      "47 bottles of beer on the wall.\n",
      "47 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "46 bottles of beer on the wall.\n",
      "\n",
      "46 bottles of beer on the wall.\n",
      "46 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "45 bottles of beer on the wall.\n",
      "\n",
      "45 bottles of beer on the wall.\n",
      "45 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "44 bottles of beer on the wall.\n",
      "\n",
      "44 bottles of beer on the wall.\n",
      "44 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "43 bottles of beer on the wall.\n",
      "\n",
      "43 bottles of beer on the wall.\n",
      "43 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "42 bottles of beer on the wall.\n",
      "\n",
      "42 bottles of beer on the wall.\n",
      "42 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "41 bottles of beer on the wall.\n",
      "\n",
      "41 bottles of beer on the wall.\n",
      "41 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "40 bottles of beer on the wall.\n",
      "\n",
      "40 bottles of beer on the wall.\n",
      "40 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "39 bottles of beer on the wall.\n",
      "\n",
      "39 bottles of beer on the wall.\n",
      "39 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "38 bottles of beer on the wall.\n",
      "\n",
      "38 bottles of beer on the wall.\n",
      "38 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "37 bottles of beer on the wall.\n",
      "\n",
      "37 bottles of beer on the wall.\n",
      "37 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "36 bottles of beer on the wall.\n",
      "\n",
      "36 bottles of beer on the wall.\n",
      "36 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "35 bottles of beer on the wall.\n",
      "\n",
      "35 bottles of beer on the wall.\n",
      "35 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "34 bottles of beer on the wall.\n",
      "\n",
      "34 bottles of beer on the wall.\n",
      "34 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "33 bottles of beer on the wall.\n",
      "\n",
      "33 bottles of beer on the wall.\n",
      "33 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "32 bottles of beer on the wall.\n",
      "\n",
      "32 bottles of beer on the wall.\n",
      "32 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "31 bottles of beer on the wall.\n",
      "\n",
      "31 bottles of beer on the wall.\n",
      "31 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "30 bottles of beer on the wall.\n",
      "\n",
      "30 bottles of beer on the wall.\n",
      "30 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "29 bottles of beer on the wall.\n",
      "\n",
      "29 bottles of beer on the wall.\n",
      "29 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "28 bottles of beer on the wall.\n",
      "\n",
      "28 bottles of beer on the wall.\n",
      "28 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "27 bottles of beer on the wall.\n",
      "\n",
      "27 bottles of beer on the wall.\n",
      "27 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "26 bottles of beer on the wall.\n",
      "\n",
      "26 bottles of beer on the wall.\n",
      "26 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "25 bottles of beer on the wall.\n",
      "\n",
      "25 bottles of beer on the wall.\n",
      "25 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "24 bottles of beer on the wall.\n",
      "\n",
      "24 bottles of beer on the wall.\n",
      "24 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "23 bottles of beer on the wall.\n",
      "\n",
      "23 bottles of beer on the wall.\n",
      "23 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "22 bottles of beer on the wall.\n",
      "\n",
      "22 bottles of beer on the wall.\n",
      "22 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "21 bottles of beer on the wall.\n",
      "\n",
      "21 bottles of beer on the wall.\n",
      "21 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "20 bottles of beer on the wall.\n",
      "\n",
      "20 bottles of beer on the wall.\n",
      "20 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "19 bottles of beer on the wall.\n",
      "\n",
      "19 bottles of beer on the wall.\n",
      "19 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "18 bottles of beer on the wall.\n",
      "\n",
      "18 bottles of beer on the wall.\n",
      "18 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "17 bottles of beer on the wall.\n",
      "\n",
      "17 bottles of beer on the wall.\n",
      "17 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "16 bottles of beer on the wall.\n",
      "\n",
      "16 bottles of beer on the wall.\n",
      "16 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "15 bottles of beer on the wall.\n",
      "\n",
      "15 bottles of beer on the wall.\n",
      "15 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "14 bottles of beer on the wall.\n",
      "\n",
      "14 bottles of beer on the wall.\n",
      "14 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "13 bottles of beer on the wall.\n",
      "\n",
      "13 bottles of beer on the wall.\n",
      "13 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "12 bottles of beer on the wall.\n",
      "\n",
      "12 bottles of beer on the wall.\n",
      "12 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "11 bottles of beer on the wall.\n",
      "\n",
      "11 bottles of beer on the wall.\n",
      "11 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "10 bottles of beer on the wall.\n",
      "\n",
      "10 bottles of beer on the wall.\n",
      "10 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "9 bottles of beer on the wall.\n",
      "\n",
      "9 bottles of beer on the wall.\n",
      "9 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "8 bottles of beer on the wall.\n",
      "\n",
      "8 bottles of beer on the wall.\n",
      "8 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "7 bottles of beer on the wall.\n",
      "\n",
      "7 bottles of beer on the wall.\n",
      "7 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "6 bottles of beer on the wall.\n",
      "\n",
      "6 bottles of beer on the wall.\n",
      "6 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "5 bottles of beer on the wall.\n",
      "\n",
      "5 bottles of beer on the wall.\n",
      "5 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "4 bottles of beer on the wall.\n",
      "\n",
      "4 bottles of beer on the wall.\n",
      "4 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "3 bottles of beer on the wall.\n",
      "\n",
      "3 bottles of beer on the wall.\n",
      "3 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "2 bottles of beer on the wall.\n",
      "\n",
      "2 bottles of beer on the wall.\n",
      "2 bottles of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "1 borrle of beer on the wall.\n",
      "\n",
      "1 borrle of beer on the wall.\n",
      "1 borrle of beer.\n",
      "Take one down.\n",
      "Pass it around.\n",
      "No more bottles of beer on the wall.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"bottles\"\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num, word,\"of beer on the wall.\")\n",
    "    print(beer_num, word,\"of beer.\")\n",
    "    print(\"Take one down.\")\n",
    "    print(\"Pass it around.\")\n",
    "    if beer_num == 1:\n",
    "        print(\"No more bottles of beer on the wall.\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"borrle\"\n",
    "        print (new_num,word,\"of beer on the wall.\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cf2c9c64",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
